package com.ticket.sass.common.ticketserver

import com.ticket.sass.common.ticketserver.configure.Config
import com.ticket.sass.common.ticketserver.configure.ConfigData
import com.ticket.sass.common.ticketserver.dto.input.*
import com.ticket.sass.common.ticketserver.enums.Platform
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class CommonTicketserverCX300Tests {

    @Autowired
    lateinit var ticketServerBuilder: TicketServerBuilder

    @Test
    fun schedules() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).schedules(ScheduleInput("2024-06-27", "2024-06-28"))

        println(res)
    }

    @Test
    fun scheduleSeatMap() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).scheduleSeatMap(ScheduleSeatMapInput(
            sessionCode = "3903202406270008",
            "",
            hallCode = "0000000000000004",
        ))

        println(res)
    }

    @Test
    fun orderTicketInfo() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).orderTicketInfo(OrderTicketInfoInput("4301112153056573"))

        println(res)
    }

    @Test
    fun seatLock() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).seatLock(SeatLockInput(
            outLockNo = "",
            sessionCode = "3903202406280068",
            scheduleKey = "",
            seatList = listOf(
                SeatLockInput.Seat("4301112107#01#02", "4301112107#01#02")
            )
        ))
    }

    @Test
    fun orderTicketSubmit() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).orderTicketSubmit(
            OrderTicketSubmitInput(
                orderNo = "20240627132830307587",
                outOrderNo = "",
                sessionCode = "3903202406280085",
                scheduleId = "",
                scheduleUpdateTime = "",
                cellphone = "13011006579",
                seatList = listOf(
                    OrderTicketSubmitInput.Seat(
                        "4301112105#02#01",
                        "4301112105#02#01",
                        26.toBigDecimal(),
                        0.toBigDecimal(),
                        0.toBigDecimal(),
                        0.toBigDecimal(),
                    )
                )
            ))
    }

    @Test
    fun orderTicketStatus() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).orderTicketStatus(OrderTicketStatusInput("3903100099240627000002", "3903100099240627000003"))
    }

    @Test
    fun halls() {
        ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).halls()
    }

    @Test
    fun orderTicketRefund() {
        ticketServerBuilder.apiBuild(Config(
            Platform.CX300,
            ConfigData.CX300("", "", "9bf823c46be6b22d39dd4487eede49b8")
        )).orderTicketRefund(OrderTicketRefundInput(
            "",
            "3903100099240628000003",
            "3903202406280085",
            listOf(
                OrderTicketRefundInput.Seat("4301112105#02#23", "4301112105#02#23")
            )
        ))
    }
}
